package com.koron.sinoprobe.web.purchase.service;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.koron.bean.query.PageQuery;
import com.koron.sinoprobe.web.purchase.bean.po.SpPurchaseEstablish;
import com.koron.sinoprobe.web.purchase.bean.query.SpPurchaseEstablishQuery;
import com.koron.sinoprobe.web.purchase.bean.vo.SpPurchaseEstablishVO;
import org.koron.ebs.mybatis.SessionFactory;

import java.util.List;

/**
 * 采购立项(SpPurchaseEstablish)表服务接口
 *
 * @author jzp
 * @since 2021-12-29 10:19:39
 */
public interface SpPurchaseEstablishService {

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    SpPurchaseEstablishVO getById(SessionFactory factory, String id);

    /**
     * 通过ID查询单条数据
     *
     * @param projectId 主键
     * @return 实例对象
     */
    SpPurchaseEstablish getByProjectId(SessionFactory factory, String projectId);

    /**
     * 查询所有数据
     *
     * @param query 查询条件对象
     * @return 列表结果集
     */
    List<SpPurchaseEstablishVO> list(SessionFactory factory, SpPurchaseEstablishQuery query);

    /**
     * 分页查询
     *
     * @param query 分页条件
     * @return 对象列表
     */
    default PageInfo<SpPurchaseEstablishVO> page(SessionFactory factory, PageQuery pageQuery, SpPurchaseEstablishQuery query) {
        PageHelper.startPage(pageQuery.getPage(), pageQuery.getPageSize(), pageQuery.getOrderBy());
        List<SpPurchaseEstablishVO> spPurchaseEstablishList = list(factory, query);
        return new PageInfo<>(spPurchaseEstablishList);
    }

    List<String> getRelated(SessionFactory factory);

    /**
     * 新增数据
     *
     * @param spPurchaseEstablish 实例对象
     * @return 是否成功
     */
    boolean saveOrUpdate(SessionFactory factory, SpPurchaseEstablish spPurchaseEstablish);

    boolean submit(SessionFactory factory, SpPurchaseEstablish spPurchaseEstablish);

    boolean end(SessionFactory factory,  String id);

    /**
     * 修改数据
     *
     * @param spPurchaseEstablish 实例对象
     * @return 是否成功
     */
    boolean update(SessionFactory factory, SpPurchaseEstablish spPurchaseEstablish);

    boolean updateStatus(SessionFactory factory, String id, String status);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    boolean deleteById(SessionFactory factory, String id);

}
